package edu.progra2.ventas.action;

import org.apache.struts2.convention.annotation.*;

import javax.persistence.*;

import java.util.*;

import edu.progra2.common.util.Utilitario;
import edu.progra2.ventas.model.*;


@Action(value="listarCli",
results={@Result(name="exito",location="/listarCli.jsp")
} )



public class ListarClienteAction {
	
	private List<Cliente> clientes;
		
	
	public String execute(){
		
		String result="exito";
		EntityManager em=
					Utilitario.getInstance().getEntityManager();
		String jpql="SELECT o FROM Cliente o";
		Query query=em.createQuery(jpql);
		clientes = query.getResultList();
		return result;
		
		
	}

	
	@Action(value="atras",
			results={@Result(name="exito",location="/menu-adm.jsp")
			} )
			public String atras(){
			String result="exito";
			return result;
			}

	public List<Cliente> getClientes() {
		return clientes;
	}

	public void setClientes(List<Cliente> clientes) {
		this.clientes = clientes;
	}
		

}
